package com.gxar.quick.ar.server.base.model.plaza.mapper;

import com.gxar.quick.ar.server.base.model.plaza.vo.response.*;
import com.gxar.quick.ar.server.db.model.PlazaEntity;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * 广场实体转换工具
 *
 * @author Linsy
 * @version 1.0
 * @created 2023/11/8 10:45 AM
 */
@Mapper
public interface PlazaMapStruct {
    PlazaMapStruct INSTANCE = Mappers.getMapper(PlazaMapStruct.class);

    /**
     * 广场实体转详情
     *
     * @param entity 实体
     * @return 响应
     */
    @Mapping(target = "id", expression = "java(String.valueOf(entity.getId()))")
    @Mapping(target = "userId", expression = "java(String.valueOf(entity.getUserId()))")
    @Mapping(target = "worksId", expression = "java(String.valueOf(entity.getWorksId()))")
    PlazaInfoResponse entityToInfoResponse(PlazaEntity entity);

    /**
     * 实体转发布广场响应
     *
     * @param entity 实体
     * @return 发布广场响应
     */
    @Mapping(target = "id", expression = "java(String.valueOf(entity.getId()))")
    @Mapping(target = "worksId", expression = "java(String.valueOf(entity.getWorksId()))")
    AdminPublishPlazaResponse entityToPublishResponse(PlazaEntity entity);

    /**
     * 实体转更新响应
     *
     * @param entity 实体
     * @return 更新响应
     */
    @Mapping(target = "id", expression = "java(String.valueOf(entity.getId()))")
    @Mapping(target = "worksId", expression = "java(String.valueOf(entity.getWorksId()))")
    AdminUpdatePlazaResponse entityToUpdateResponse(PlazaEntity entity);

    /**
     * 列表转管理端分页列表
     *
     * @param response 列表
     * @return 管理端分页列表
     */
    AdminPlazaPageListResponse listToPageListResponse(PlazaListResponse response);

    /**
     * 列表转管理端分页列表
     *
     * @param response 列表
     * @return 管理端分页列表
     */
    List<AdminPlazaPageListResponse> listToPageListResponse(List<PlazaListResponse> response);

    /**
     * 实体转详情
     *
     * @param entity 实体
     * @return 详情
     */
    @Mapping(target = "id", expression = "java(String.valueOf(entity.getId()))")
    @Mapping(target = "userId", expression = "java(String.valueOf(entity.getUserId()))")
    @Mapping(target = "worksId", expression = "java(String.valueOf(entity.getWorksId()))")
    AdminPlazaInfoResponse entityToDetail(PlazaEntity entity);
}
